import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

import org.apache.axis.AxisFault;

import redarrow.wb.output.AddUrlOutput;
import redarrow.wb.output.GenUserOutput;
import redarrow.wb.output.ListUserWebOutput;
import redarrow.wb.service.WebbookServiceSoapBindingStub;


public class test {
	public static void main(String args[]){
	
		try {
			URL url = new URL("http://localhost:8080/WebBookService/services/webbookService?wsdl");
			WebbookServiceSoapBindingStub services;
			services = new WebbookServiceSoapBindingStub(url, null);
			AddUrlOutput output=new AddUrlOutput();
//			output = services.addUrl("hongson", "ss");
//			System.out.println(output.getCode());
//			System.out.println(output.getMessage());
//			
			
//			//nguoi dung tu gen ra 1 user name bat ky, password hien tai de null
//			GenUserOutput testGenUser=new GenUserOutput();			
//			testGenUser=services.createUser("hongson1", "", getCurrentTimeStamp(), "1");
//			System.out.println(testGenUser.getMessage());
	
			//get list cua username hongson
			ListUserWebOutput listWeb=new ListUserWebOutput();
			listWeb=services.getListUserWeb("hongson");
			System.out.println(listWeb.getCode());
			System.out.println(listWeb.getMessage());
		    String[] listUrl=listWeb.getListUrl();		    
		    int size = listUrl.length;
		    for (int i = 0 ; i < size ; i++){
		    	System.out.println(listUrl[i]);
		    }
//		    
		} catch (MalformedURLException | RemoteException e) {
			// TODO Auto-generated catch block

			e.printStackTrace();
		}
		
		
		
		
	}
	
	
	public static String getCurrentTimeStamp() {
	    SimpleDateFormat sdfDate = new SimpleDateFormat("dd-MM-YYYY HH:mm:ss");//dd/MM/yyyy
	    Date now = new Date();
	    String strDate = sdfDate.format(now);
	    return strDate;
	}
	
}
